home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / demos / filebuf2demo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-08  |  1.7 KB  |  53 lines

  1. {
  2. GPC demo program. You can check the next character of a text file
  3. without reading it. So you can read an integer after checking that
  4. really a digit is following, without having to read the integer into
  5. a string and convert it afterwards. (This is a Standard Pascal
  6. feature missing in many popular Pascal compilers.)
  7.  
  8. Copyright (C) 1999-2001 Free Software Foundation, Inc.
  9.  
  10. Author: Frank Heckenbach <frank@pascal.gnu.de>
  11.  
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License as
  14. published by the Free Software Foundation, version 2.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program; see the file COPYING. If not, write to
  23. the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. Boston, MA 02111-1307, USA.
  25.  
  26. As a special exception, if you incorporate even large parts of the
  27. code of this demo program into another program with substantially
  28. different functionality, this does not cause the other program to
  29. be covered by the GNU General Public License. This exception does
  30. not however invalidate any other reasons why it might be covered
  31. by the GNU General Public License.
  32. }
  33.  
  34. program FileBufferDemo2;
  35.  
  36. var
  37.   n : Integer;
  38.   s : String (4096);
  39.  
  40. begin
  41.   Write ('Enter a (non-negative) number or a string: ');
  42.   if Input^ in ['0' .. '9'] then
  43.     begin
  44.       Readln (n);
  45.       Writeln ('The number was ', n)
  46.     end
  47.   else
  48.     begin
  49.       Readln (s);
  50.       Writeln ('The string was `', s, '''')
  51.     end
  52. end.
  53.